import { getRoomInfo } from "@/api/roomApi";
import { runInAction, makeObservable, observable, action } from "mobx";
interface roomInfoType {
  room_id: number;
  room_title: string;
}
class RoomStore {
  roomInfo: roomInfoType | undefined;
  room_id: string | undefined;
  constructor() {
    makeObservable(this, {
      room_id: observable,
      roomInfo: observable,
      getRoomInfo: action,
    });
  }
  async getRoomInfo() {
    const res = await getRoomInfo();
    runInAction(() => {
      localStorage.setItem("room_id", res.data.room_id);
      this.roomInfo = res.data;
    });
  }
  setRoomId(room_id: string) {
    this.room_id = room_id;
  }
}
const roomStore = new RoomStore();
export default roomStore;
